// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_delete_ok.java

package purchase.purchase;

import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataTag;

public class check_delete_ok extends HttpServlet
{

	public check_delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			nseer_db_backup1 purchase_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 purchase_db1 = new nseer_db_backup1(dbApplication);
			if (purchase_db.conn((String)dbSession.getAttribute("unit_db_name")) && purchase_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				ValidataTag vt = new ValidataTag();
				String purchase_ID = request.getParameter("purchase_ID");
				String choice = request.getParameter("choice");
				String checker = request.getParameter("checker");
				String check_time = request.getParameter("check_time");
				String bodyb = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
				String remark = exchange.toHtml(bodyb);
				if (vt.validata((String)dbSession.getAttribute("unit_db_name"), "purchase_purchase", "purchase_ID", purchase_ID, "check_tag").equals("1"))
				{
					try
					{
						String sql = (new StringBuilder("update purchase_purchase set remark='")).append(remark).append("',checker='").append(checker).append("',check_time='").append(check_time).append("',check_tag='9' where purchase_ID='").append(purchase_ID).append("'").toString();
						purchase_db.executeUpdate(sql);
						String sql1 = (new StringBuilder("select * from purchase_purchase where purchase_ID='")).append(purchase_ID).append("'").toString();
						for (ResultSet rs1 = purchase_db.executeQuery(sql1); rs1.next();)
						{
							String sql4;
							for (StringTokenizer tokenTO = new StringTokenizer(rs1.getString("apply_id_group"), ", "); tokenTO.hasMoreTokens(); purchase_db1.executeUpdate(sql4))
								sql4 = (new StringBuilder("update purchase_apply set purchase_tag='0' where id='")).append(tokenTO.nextToken()).append("'").toString();

						}

					}
					catch (Exception ex)
					{
						ex.printStackTrace();
					}
					response.sendRedirect("purchase/purchase/check_list.jsp");
				} else
				{
					response.sendRedirect("purchase/purchase/check_delete_ok_b.jsp");
				}
				purchase_db.commit();
				purchase_db1.commit();
				purchase_db.close();
				purchase_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
